Class Tile
- java.lang.Object
-
- page.codeberg.terratactician_expandoria.world.tiles.Tile
-
- Direct Known Subclasses:
BeehiveTile,ChameleonTile,DoubleHouseTile,ForestTile,GrassTile,MarketplaceTile,MoaiTile,RgbTile,SmallHouseTile,SoundTile,StoneHillTile,StoneMountainTile,StoneQuarryTile,StoneRocksTile,WheatTile,WindmillTile
public abstract class Tile extends java.lang.ObjectAbstract class for a tile. A tile is entity/card/building placed or placeable on the map.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classTile.TileTypeEncodes all Tile variants.
-
Field Summary
Fields Modifier and Type Field Description CubeCoordinatecoordCoordinate of this tile.floatreclaimTimeTime left to reclaim (pick up again) a Tile.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract Tileclone()Creates a clone of the tile.java.lang.StringdataToString()Can be used by tile to add internal data to `toString`.static Tiledeserialize(java.lang.String json)Deserializes a Tile without data.static Tiledeserialize(org.json.JSONObject json)Deserializes a Tile with data.CubeCoordinategetCoordinate()Returns Coordinate of Tile.abstract java.lang.StringgetName()Name of Tile in Api interface.Tile.TileTypegetTileType()Return TileType of the current tile.booleanreclaimable()Returns whether a tile can be taken again.org.json.JSONObjectserialize()serializes a tile to a json object.org.json.JSONObjectserializeData()Serializes extra Data of an Tile, to be send.booleantakeable()Returns whether a tile can be taken again.java.lang.StringtoString()
-
-
-
Field Detail
-
coord
public CubeCoordinate coord
Coordinate of this tile. This may be null if tile is not placed.
-
reclaimTime
public float reclaimTime
Time left to reclaim (pick up again) a Tile. NaN if a tile is not pickup able.
-
-
Method Detail
-
clone
public abstract Tile clone()
Creates a clone of the tile.- Overrides:
clonein classjava.lang.Object- Returns:
- the new tile
-
getCoordinate
public CubeCoordinate getCoordinate()
Returns Coordinate of Tile.- Returns:
- coordinate of the tile
-
reclaimable
public boolean reclaimable()
Returns whether a tile can be taken again. This will cost a small amount of resources.- Returns:
- if tile is reclaimable
-
takeable
public boolean takeable()
Returns whether a tile can be taken again. This will cost a small amount of resources.- Returns:
- if tile is takeable
-
serializeData
public org.json.JSONObject serializeData()
Serializes extra Data of an Tile, to be send.- Returns:
- null or JSONObject with at least a valid "type" field.
-
getName
public abstract java.lang.String getName()
Name of Tile in Api interface.- Returns:
- api name of the tile
-
getTileType
public Tile.TileType getTileType()
Return TileType of the current tile.- Returns:
- RileType of this tile
-
deserialize
public static Tile deserialize(org.json.JSONObject json)
Deserializes a Tile with data. Takes a JSONObject as argument and tries to parse it. Returns null on error.- Parameters:
json- json data- Returns:
- Event or null on error.
-
deserialize
public static Tile deserialize(java.lang.String json)
Deserializes a Tile without data. Takes a String as argument and tries to parse it. Returns null on error.- Parameters:
json- json data- Returns:
- Event or null on error.
-
serialize
public org.json.JSONObject serialize()
serializes a tile to a json object.- Returns:
- json data
-
dataToString
public java.lang.String dataToString()
Can be used by tile to add internal data to `toString`. Returned string should start with: ", "- Returns:
- additional data stringified
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-